/*
 * Copyright (C) 2013 Daniel Wasilew <daniel.wasilew@codeminer.org>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.codeminer.parts.server.actions;

import org.codehaus.jackson.annotate.JsonAnyGetter;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Daniel Wasilew <daniel.wasilew@codeminer.org>
 */
public class Response {

    public static Response createOK() {
        return new Response("OK");
    }

    public static Response createError() {
        return new Response("ERROR");
    }

    private final String type;

    private final Map<String, Object> properties = new HashMap<>();

    public Response(String type) {
        this.type = type;
    }

    public Response addProperty(String key, Object property) {
        this.properties.put(key, property);
        return this;
    }

    @JsonAnyGetter
    public Map<String, Object> getProperties() {
        return properties;
    }

    public String getType() {
        return type;
    }
}
